package com.yesjpt.web;

import com.yesjpt.domain.User;
import com.yesjpt.serv.EnvServ;
import com.yesjpt.util.L;
import com.yesjpt.util.MailUtil;
import com.yesjpt.util.SpringUtil;
import com.yesjpt.util.WebSocketServer;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/base") // 上下文路径
public class BaseController {
	//读取环境变量
	@GetMapping("/getConfig")
    public Object getConfig() {
		L.begin(new Throwable().getStackTrace()[0]);
    	return SpringUtil.getBean(EnvServ.class).getConfig();
    }
	@GetMapping("/findById")
    public Object findById(String id) {
		L.begin(new Throwable().getStackTrace()[0]);
		User user = new User(id, "user_00" + id);
		return user;
    }
	@GetMapping("/sendMail")
    public Object sendMail(String to, String subject, String content) {
		L.begin(new Throwable().getStackTrace()[0]);
		return MailUtil.send(to, subject, content);
    }
	@GetMapping("/getCidSet")
    public Object getCidSet(String to, String subject, String content) {
		L.begin(new Throwable().getStackTrace()[0]);
		return WebSocketServer.getCidSet();
    }
}
